import java.util.Arrays;

public class Test {

    public static void moveZeroes(int[] nums) {
        int cur = 0;
        int dest = -1;
        while (cur < nums.length){
            if (nums[cur]==0){
                cur++;
            }else {
                dest++;
                int tmp = nums[dest];
                nums[dest] = nums[cur];
                nums[cur] = tmp;
                cur++;
            }
        }

    }

    public static void main(String[] args) {
        int[] nums = {1,0,2,3,0,4,5,6,0,8};
        moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }




}
